<%@page import="com.wanmait.cookbook.vo.OfficialNews"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.cookbook.vo.Userinfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%String path = request.getContextPath();
    Userinfo userinfo =(Userinfo)session.getAttribute("userinfo");
    %>
<!DOCTYPE html>
<!-- saved from url=(0039)https://www.douguo.com/message/remind/3 -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <%int count1 = (int)request.getAttribute("count1");
int count2 = (int)request.getAttribute("count2");
int count3 = (int)request.getAttribute("count3");
int count4 = (int)request.getAttribute("count4");
%> 
    
    <title>提醒</title>
    <link rel="icon" href="https://cp1.douguo.com/static/nweb/images/favicon.ico?v=1912" type="image/x-icon">
    <link rel="stylesheet" href="<%=path %>/static/css/main.css">
    <link rel="stylesheet" href="<%=path %>/static/css/remind.css">
    <script src="./news_files/hm.js.下载"></script><script src="./news_files/jquery.js.下载"></script>
    <script data-ad-client="ca-pub-6608973961595981" async="" src="./news_files/f.txt"></script>
<style>.one-pan-tip { cursor: pointer;}.one-pan-tip::before {background-position: center;background-size: 100% 100%;background-repeat: no-repeat;box-sizing: border-box;width: 1em;height: 1em;margin: 0 1px .15em 1px;vertical-align: middle;display: inline-block;}.one-pan-tip-success::before {content: '';background-image: url()}.one-pan-tip-error {text-decoration: line-through;}.one-pan-tip-error::before {content: '';background-image: url()}.one-pan-tip-other::before {content: '';background-image: url()}.one-pan-tip-lock::before{content: '';background-image: url()}</style><meta name="ljjc::status" content="on"></head>
<body>
<jsp:include page="/inc/head.jsp"></jsp:include>
<div id="content" class="clearfix">
    <div class="type-head clearfix" style="margin-top:15px;">
        <a href="<%=path %>/NewsServlet?action=commentNews&id=<%=userinfo.getId() %>" one-link-mark="yes">评论及回复(<span style="color:red"><%=count2 %></span>)</a>
        <a href="<%=path %>/NewsServlet?action=collectNews&id=<%=userinfo.getId() %>" class="active" one-link-mark="yes">收藏及喜欢(<span id="spp" style="color:red"><%=count3 %></span>)</a>
        <a href="<%=path %>/NewsServlet?action=attentionNews&id=<%=userinfo.getId() %>" one-link-mark="yes">关注提醒(<span style="color:red"><%=count4 %></span>)</a>
        <a href="<%=path %>/NewsServlet?action=officialNews&id=<%=userinfo.getId() %>" one-link-mark="yes">官方通知(<span style="color:red"><%=count1 %></span>)</a>
        <a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        	&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
        </a>
        <a style="color:red;" id="delAll" href="javascript:void(0)">批量删除已读</a> 
    </div> 
    <% List<OfficialNews> news = (List<OfficialNews>)request.getAttribute("news");%>
    <ul id="tyt" class="remind-list mh600  msglist ">
    <%for(int i=0;i<news.size();i++){ 
    	if(news.get(i).getStatus()){
    %>	
            <li class="item clearfix relative" id="del<%=news.get(i).getId()%>" >
            <img class="m" data-id="<%=news.get(i).getId() %>" width="10" src="">
                <a href="javacsript:void(0)" class="user-img" one-link-mark="yes">
                    <img height=50 src="<%=path %>/static/image/<%=news.get(i).getUserinfo().getAvatar() %>" alt="PurpleStyle">
                </a>
                <div class="info">
                    <a class="nickname" href="#" one-link-mark="yes"><%=news.get(i).getUserinfo().getName() %></a>
                    <p class="msg"> <%=news.get(i).getContent() %></p>
                </div>
                <div class="operating">
                
                    <a href="javascript:;" data-id="<%=news.get(i).getId() %>"  class="delete" style="visibility: hidden" one-link-mark="yes">删除</a>
                </div>
                <p class="time"><%=news.get(i).getInputTime() %></p>
            </li>
         
            <%}else{ %>
           
	              <li class="item clearfix relative" id="del<%=news.get(i).getId()%>" >
	            	<img class="m" data-id="<%=news.get(i).getId()%>" width="10" src="<%=path%>/static/image/red.jpg">
	                <a href="javacsript:void(0)" class="user-img" one-link-mark="yes">
	                    <img src="<%=path %>/static/image/<%=news.get(i).getUserinfo().getAvatar() %>" alt="PurpleStyle">
	                </a>
	                <div class="info">
	                    <a class="nickname" href="#" one-link-mark="yes"><%=news.get(i).getUserinfo().getName() %> </a>
	                    <p class="msg"> <%=news.get(i).getContent() %></p>
	                </div>
	                <div class="operating">
	                
	                    <a href="javascript:;" data-id="<%=news.get(i).getId() %>"  class="delete" style="visibility: hidden" one-link-mark="yes">删除</a>
	                </div>
	                <p class="time"><%=news.get(i).getInputTime() %></p>
	            </li>
	        
            <%}} %>
   </ul>
   <!--  <div id="loading" class="loading" style="text-align: center;padding-top: 20px"></div> -->
        <!-- <div class="deleteAll clearfix">
        <a href="javascript:;" onclick="emptyMsg('18632081','3','Dduv912OQEpXitDcHEKfFVZGOC4nnF1cuIf9TJRM')" class="delete">删除全部提醒</a>
    </div> -->
        <p class="fcc">你当前的位置：<a href="<%=path %>/" target="_blank" one-link-mark="yes">南瓜美食</a> &gt; 消息中心</p>
</div>
<script>
    var group_id="3"=="7"?"4":"3",offset=20,isFetch=false,isEnd=0;token="Dduv912OQEpXitDcHEKfFVZGOC4nnF1cuIf9TJRM";
    $(window).scroll(function(){
        var pheight = window.screen.availHeight;
        var documentHeight = document.body.scrollHeight;
        var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
        if(scrollTop + pheight>documentHeight - 80 && isFetch != true && isEnd !=1) {
            showLoading();
            getlist();
        }
    });
    function getlist(){
        isFetch=true;
        $.ajax({
            url:"/message/remind/"+group_id+"/"+offset,
            type:'get',
            success:function(res){
                var lists = res.data.list;
                if(res.errcode==0 && lists){
                    hideLoading();
                    var len  = lists.length;
                    var html = "";
                    for(var i=0;i<len;i++){
                        if(typeof lists[i]["qp"] == 'undefined'){
                            lists[i]["qp"] = '';
                        }
                        if(typeof lists[i]["qc"] == 'undefined'){
                            lists[i]["qc"] = '';
                        }
                        item = '<li class="item clearfix" data-id="'+lists[i]["id"]+'"><p class="time">'+lists[i]["createdate"]+'</p><a href="/u/'+lists[i]['user']["username"]+'.html" class="user-img"> <img src="'+lists[i]['user']["headicon"]+'" alt="'+lists[i]['user']["nickname"]+'"></a>';
                        if(group_id==3){
                            item +='<div class="info"><a class="nickname" href="/u/'+lists[i]['user']["username"]+'.html">'+lists[i]['user']["nickname"]+'</a> <p class="msg">'+lists[i]["qp"]+lists[i]["qc"]+lists[i]["content"]+'</p></div><div class="operating">';
                        }else{
                            item +='<div class="msginfo"><a class="nickname" href="/u/'+lists[i]['user']["username"]+'.html">'+lists[i]['user']["nickname"]+'</a>  <p class="msg">'+lists[i]["qp"]+lists[i]["qc"]+lists[i]["content"]+'</p></div><div class="operating">';
                        }
                        if(lists[i]["object_image_url"]){
                            var img_url = lists[i]["object_image_url"];
                            var uid = '18632081';
                            var id = lists[i]["id"];
                            var token = 'Dduv912OQEpXitDcHEKfFVZGOC4nnF1cuIf9TJRM';
                            item +='<a class="cover" style="background: url() no-repeat center center;background-size:cover;" href="' + img_url + '"></a> <a href="javascript:;" onclick="delMsg(this,'+ uid  +','+ id +','+ token +')" class="delete" style="visibility: hidden">删除</a>';
                        }else{
                            item += '<a href="javascript:;" onclick="delMsg(this,\'+ uid  +\',\'+ id +\',\'+ token +\')" class="delete" style="visibility: hidden">删除</a>';
                        }
                        item += '</div></li>';
                        html += item;
                    }
                    $(".remind-list").append(html);
                    offset += 20;
                    isFetch=false;
                    isEnd = res.data.end;
                }
            }
        })
    }
    function delMsg(that,user_id,id,token) {
        showMotai('确认删除信息吗？',function(){
            $.ajax({
                url:"/message/del/",
                data:{'user_id':user_id,'msg_id':id,'_token':token},
                type:'post',
                success:function(res){
                    // tip({text:res.msg});
                    $(that).parents().parents("li").remove();
                }
            })
        });
    }
    function emptyMsg(user_id,group_id,token) {
        showMotai('是否删除所有消息？',function(){
            $.ajax({
                url:"/message/empty/",
                data:{'user_id':user_id,'type':group_id,'_token':token},
                type:'post',
                success:function(res){
                    // tip({text:res.msg});
                    $(".remind-list").html("");
                }
            })
        });
    }
    $.ajax({
        url:"/message/unread",
        data:{'user_id':'18632081'},
        type:'get',
        success:function(res){
            if(res.data.unread_count > 0){
                $("#header").find(".msgnum").show();
            }else{
                $("#header").find(".msgnum").hide();
            }
            $("#header").find(".msgnum").text(res.data.unread_count);
        }
    })
    
    function showLoading() {
        let load = '<img style="display:inline-block;width:13px" src="https://cp1.douguo.com//static/nweb/images/loading.gif"><span style="    margin-left: 10px;font-size: 13px;line-height: 10px;">正在加载中....</span>'
        hideLoading();
        $('#loading').append(load);
    }
    function hideLoading() {
        $("#loading").empty();
    }
</script>
<jsp:include page="/inc/foot.jsp"></jsp:include>
<script src="./news_files/tip.js.下载"></script>
<script src="./news_files/search.js.下载"></script>
<script src="./news_files/main.js.下载"></script>
<!-- <script src='https://s13.cnzz.com/c.php?id=30029854' language='JavaScript' charset='gb2312'></script> -->

</body></html>
<script>
$(function(){
	$(".delete").click(function(){
		var th = $(this);
		var id = $(this).data("id");
		$.ajax({
			url:"<%=path%>/NewsServlet?action=deleteOfficialNews",
			data:{id:id},
			success:function(){
				th.parent().parent().remove();
			}
		})
		
	});
	//未读变已读
	$("#tyt li").click(function(){
		var sp = $("#spp").html();
		var yu = $("#count").html();
		var id= $(this).attr("id").substring(3);
		var sr = $(this).children().first().attr("src");
		var th =$(this);
		if(sr!=""){
			$.ajax({
				url:"<%=path%>/NewsServlet?action=setHaveRead",
				data:{id:id},
				success:function(){
					th.children().first().attr("src","");
					$("#spp").html(sp-1);
					$("#count").html(yu-1);
					$("#count1").html(yu-1);
				}
			})
		}
	})
	
	
	$("#delAll").click(function(){
		 var  idArr = [];
		 $(".m").each(function(){
			 var sr=$(this).attr("src");
			 var id =$(this).data("id");
			 if(sr==""){
				idArr.push(id); 
			 }
		 });
			 if(idArr.length>0){
				 $.get("<%=path%>/NewsServlet?action=deleteAllNews",
						 {ids:idArr.toString()},
						 function(){
							
							 for(var i=0;i<idArr.length;i++){
								 $("#del"+idArr[i]).remove();
							 }
						 })
			 }
		 
	});
	
})
</script>